from networkFramework import *
from framework import *
from dataStruct import snapshotStruct as sStruct
import time

def main():
    configData = getSSConfig()
    
    if len(sys.argv) == 3:
        host = sys.argv[1]
        port = int(sys.argv[2])
    else:
        host = configData['host']
        port = configData['port']
        
    timer = time.time() +5
    
    bookObj = sStruct()
    buffSize = bookObj.buffSize
    
    bRecSock = reciverUDPConn(host, port, buffSize)
    
    
    while True:
        bookObj = sStruct()
        bookObj.buffer = bRecSock.recData()
        try:
            bookList = bookObj.getValues()
            printBook(bookList)

        except:
            out = "Error: Timed out"

    bRecSock.close()

if __name__ == "__main__":
    main()